﻿@{
    ViewBag.Title = "个人设置";
    Layout = "~/Views/Shared/_LayoutFore.cshtml";
    /*  QJ.CMS.Controllers.AccountController.path = new LY.Common.Utils.ReturnParameters();*/
}
@model LY.Entity.U_Member
@section script{
    <script src="~/Content/assets/DatePicker/WdatePicker.js"></script>
    <script src="~/Content/assets/app/common/ajaxupload.js"></script>
    <script type="text/javascript">

        //图片上传初始化
        var util = {};
        var options = {
            uploadUrl: "@Url.Action("UploadImg", "Helper")"
        };
        //初始化  
        var g_AjxTempDir = "/FileUpload/";

        function init(img, show, file) {
            //初始化图片上传  
            var btnImg = img;
            var img = show;
            var TitlePic = "个人头像";
            var Pictures = "111";
            var fileName = file;
            g_AjxUploadImg(btnImg, img, TitlePic, Pictures, fileName);
        }

        //图片上传  

        function g_AjxUploadImg(btn, img, TitlePic, Pictures, fileName) {
            var button = btn, interval;
            new AjaxUpload(button, {
                action: options.uploadUrl,
                data: {},
                name: 'myfile',
                onSubmit: function (file, ext) {
                    if (!(ext && /^(jpg|JPG|png|PNG|gif|GIF)$/.test(ext))) {
                        alert("您上传的图片格式不对，请重新选择！");
                        return false;
                    }
                },
                onComplete: function (file, response) {
                    flagValue = response;
                    if (flagValue == "-1") {
                        alert("您上传的图片格式不对，请重新选择！");
                    } else if (flagValue == "-2") {
                        alert("您上传的图片大于200K，请重新选择！");
                    } else if (flagValue == "-3") {
                        alert("图片上传失败！");
                    } else {
                        var strs = new Array();
                        strs = response.split("/");

                        var Pictures2 = "";
                        var fileName2 = "";
                        for (var i = 0; i < strs.length; i++) {
                            if (i == 0) {
                                TitlePic.value = strs[i];
                            } else if (i == 1) {
                                Pictures.value = strs[i];
                                Pictures2 = strs[i];

                            } else if (i == 2) {
                                fileName2 = strs[i];
                            }
                        }
                        img.src = g_AjxTempDir + fileName2 + "/" + Pictures2;
                        fileName.value = g_AjxTempDir + fileName2 + "/" + Pictures2;
                    }
                }
            });
        }

        function OnSuccess(data) {
            if (data.Status == 1) {
                $.dialog.tips(data.Message, 1, 'tips.gif', function () {
                    window.location.href = "/Account/index";
                });
            } else {
                alert(data.Message);
                return false;
            }
            return false;
        }

        $(function () {
            $("form").Validform({
                tiptype: 3
            });
            if ('@Model.Email' == "") {
                $("#aEmail").html("点击立即绑定");
            } else {
                $("#aEmail").html("点击立即更换");
            }
            var btnImg = document.getElementById("btnUploadImg");

            var fileName = document.getElementById("fileName");

            var img = document.getElementById("imgShow");
            init(btnImg, img, fileName);
        }); </script>
    <style>
        .tab-content dl dt:first-child {
            width: 80px;
            text-align: right;
        }

        #btnUploadImg {
            text-align: center;
            line-height: 20px;
            height: 20px;
            margin: 8px 0px 0px 0px;
            padding: 0px;
            border: 0px;
            float: left;
            width: 120px;
            height: 25px;
            font-size: 10pt;
        }

        em {
            float: left;
            margin: 0px 10px;
            color: #333;
        }

        #imgShow {
            margin: 5px 0px 0px 80px;
        }
    </style>
}

<div class="RightContrent">
    <div style="margin-left: 50px; margin-right: 50px;">
        <div class="tab-content">
            <div class="line10"></div>
            <div class="line10"></div>
            <div class="tab_title">@ViewBag.Title</div>
            <div class="tab-content">
                <div style="width: 16px; height: 12px; float: left;">
                    <img src="~/Content/Images/leftarraw.png" />
                </div>
            </div>

            <div class="tab-content_border">

                <div class="u-center">
                    <div class="u-form-wrap">
                        @using (Ajax.BeginForm("PersonSet", new AjaxOptions() { OnSuccess = "OnSuccess" }))
                        {
                            <input type="hidden" name="ID" id="ID" value="@Model.ID"/>
                            <div class="tab-content">
                                <dl>
                                    <dt>昵称：</dt>
                                    <dd id="SignMsg">
                                        @Html.TextBox("Nickname", Model.Nickname, new { @class = "input  normal", id = "userName", datatype = "regName", ajaxurl = "/tools/AdminAjax.ashx?action=validate_user&name=" + Model.Nickname + "" })
                                        @*  <input id="Name" class="input  normal" disabled="disabled" type="text" value="@Model.RealName" />*@
                                    </dd>

                                    @*<dt>真实姓名：</dt>
                                    <dd id="SignMsg">
                                        @#1#Html.TextBox("Name", Model.Name, new { @class = "input  normal", id = "userName", datatype = "regName", ajaxurl = "/tools/AdminAjax.ashx?action=validate_user&name=" + Model.Name + "" })#1#
                                        <input id="Name" class="input  normal" disabled="disabled" type="text" value="@Model.RealName" />
                                    </dd>*@
                                </dl>
                                <dl>
                                    <dt>性别：</dt>
                                    <dd>@Html.ResourceRadioList("Sex", "GENDER2", Model.Sex, new { @class = "input select" })</dd>
                                </dl>
                                <dl>
                                    <dt>生日：</dt>
                                    <dd>@Html.TextBox("Birthday", Model.Birthday.ToString("yyyy-MM-dd"), new { @class = "input  normal", @onclick = "WdatePicker();" })</dd>
                                </dl>
                                <dl>
                                    <dt>地址：</dt>
                                    <dd>@Html.TextBox("Address", Model.Address, new { @class = "input  normal" })</dd>
                                </dl>
                                <dl>
                                    <dt>邮箱：</dt>
                                    <dd>
                                        <input class="input  normal" type="text" disabled="disabled" value="@Model.Email" />
                                        &nbsp;&nbsp;
                                         <a id="aEmail" href="/Account/EmailCertification" style="color: red"></a>
                                    </dd>
                                </dl>
                                <dl>
                                    <dt>手机号码：</dt>
                                    <dd>
                                        <input type="text" class="input  normal" disabled="disabled" value="@Model.Mobilenumber" />&nbsp;&nbsp;
                                        <a href="/Account/PhoneCertification" style="color: red">点击立即更换</a>
                                    </dd>

                                </dl>
                                <dl>
                                    <dt>头像：</dt>
                                    <dd class="">
                                        <input type="button" id="btnUploadImg" value="上传头像" class="button" />
                                        <em>支持jpg、jpeg、png、gif格式,请上传120px*120px的图片,如果超过尺寸可能会变形</em>
                                    </dd>

                                </dl>
                                <dl>
                                    <dd>
                                        <img id="imgShow" class="upload-img1" style="width: 120px; height: 120px" src="@Model.HeadImage"/>
                                        <input type="hidden" id="fileName" name="HeadImage" value="@Model.HeadImage" />
                                    </dd>
                                </dl>
                                <dl>
                                    <dd style="margin-left: 80px">
                                        <input type="submit" value="提交" id="btnSave" class="btn" />
                                        <a href='@Url.Action("Index")' class="btn" style="color:white">返回</a>
                                    </dd>
                                </dl>
                            </div>
                        }

                    </div>
                </div>

            </div>
        </div>
    </div>

</div>
